/*
 * Copyright 2006 Brian Watkins
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */


package bw.util;

import org.apache.commons.logging.LogFactory;

public class Log
{    
    private static Log _instance = null;
    private static Object _lock = new Object();

    private org.apache.commons.logging.Log _logger = null;

    public static Log getInstance ()
    {
        if ( _instance == null ) 
        {
            synchronized ( _lock ) 
            {
                if ( _instance == null ) 
                {
                    _instance = new Log();
                }
            }
        }

        return _instance;
    }

    private Log ()
    {
        try {
            _logger = LogFactory.getLog( Log.class );
            _logger.info( "Log: Hello world." );
        }
        catch ( Exception ex ) { }
    }

    public void write ( String msg, Exception ex ) 
    {
        _logger.info( msg, ex );
    }

    public void write ( String msg )
    {
        _logger.info( msg );
    }

    public void write ( Exception ex )
    {
        _logger.info( ex );
    }

    public void write ( Object obj )
    {
        write( obj.toString() );
    }

    public void shutdown ()
    {
        //LogManager.shutdown();
    }
}